package eu.vranckaert.workRegistrationWidget.service;

import android.content.Context;
import android.location.Location;
import com.google.inject.ImplementedBy;
import eu.vranckaert.workRegistrationWidget.activities.ExportActivity;
import eu.vranckaert.workRegistrationWidget.activities.ResultsActivity;
import eu.vranckaert.workRegistrationWidget.domain.TimeRegistration;
import eu.vranckaert.workRegistrationWidget.exceptions.EndDateBeforeStartDateException;
import eu.vranckaert.workRegistrationWidget.service.impl.RegistrationServiceImpl;

import java.io.File;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * @Author Dirk Vranckaert
 * Date: 23-apr-2010
 * Time: 19:05:40
 */
@ImplementedBy(RegistrationServiceImpl.class)
public interface RegistrationService {
    /**
     * Creates a new time registration for the current moment in time.
     * @param context The context.
     * @return The registered time.
     * @throws eu.vranckaert.workRegistrationWidget.exceptions.EndDateBeforeStartDateException If the dates are messed
     * up and the time to register is before the starting date this exception occurs.
     */
    TimeRegistration createRegistrationForCurrentTime(Context context) throws EndDateBeforeStartDateException;

    /**
     * Retrieves all the time registrations stored on the device.
     * @param context The context.
     * @return All the time registrations.
     */
    List<TimeRegistration> getAllTimeRegistrations(Context context);

    /**
     * Retrieves the latest time registration avaailable in the database.
     * @param context The context.
     * @return A time registration.
     */
    TimeRegistration getLatestTimeRegistration(Context context);

    /**
     * Deletes all registrations available in the database.
     * @param context The context.
     */
    void removeAllRegistrations(Context context);

    /**
     * Deletes a single {@link eu.vranckaert.workRegistrationWidget.domain.TimeRegistration} instance.
     * @param context The context.
     * @param timeRegistration The registration to delete.
     */
    void removeRegistration(Context context, TimeRegistration timeRegistration);

    /**
     * Updates a single {@link eu.vranckaert.workRegistrationWidget.domain.TimeRegistration} instance.
     * @param context The context.
     * @param timeRegistration The registration to update.
     */
    void saveOrUpdateRegistration(Context context, TimeRegistration timeRegistration);

    /**
     * Create and save the export file.
     * @param startCal The start date to start the export.
     * @param endCal The end date to end the export.
     * @param fileName The name of the file witouth the extension
     * @param context The context.
     * @return The save {@link java.io.File} instance.
     */
    File export(Calendar startCal, Calendar endCal, String fileName, Context context);
}
